#include "chemnitz.h"
/*@-compdef@*/
#include "openssl/aes.h"
/*@+compdef@*/

static char version [128];
static char *vers = "libchemnitz version 0";

static char *impl = "AES-128";
// Let us annotate the openssl function so splint can tell what it does.
/*@-incondefs@*/
extern int AES_set_encrypt_key (const unsigned char *userKey, const int bits,
        /*@out@*/ AES_KEY *key);
/*@+incondefs@*/

void chemnitz_encrypt (const uint8_t *plaintextblock, const uint8_t *key, const uint8_t *ciphertextblock)
{
	AES_KEY k;

	memset ((void *) ciphertextblock, 0, 16);
	(void) AES_set_encrypt_key ((unsigned char *) key, 128, &k);
	(void) AES_encrypt ((unsigned char *) plaintextblock, (unsigned char *) ciphertextblock, &k);
}

void chemnitz_version (char **buffer)
{
	(void) snprintf (version, 128, "%s+%s", vers, impl);
	*buffer = version;
}

